package com.cmlite.connect;
import android.app.AlertDialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.cmlite.R;
public class ScreenStopper extends AlertDialog {
	public static final int STYLE_NONE = -1;
	public static final int STYLE_STOPPER = 0;
	public static final int STYLE_PROGRESS_PROCESS	= 1;
	public static final int STYLE_PROGRESS_VOTE	= 2;
	public static final int STYLE_PROGRESS_DRAFT	= 3;
	public static final int STYLE_PROGRESS_LOADING	= 4;

	public ScreenStopper(Context context)
	{
	    super(context, android.R.style.Theme_Translucent);   
	    
		createView(context, STYLE_STOPPER);
	}
	
	
	public ScreenStopper(Context context, int style) 
	{  
	    super(context);   

		createView(context, style);
	}
	
	
	static ScreenStopper createScreenStopperTrans(Context context)
	{
		return new ScreenStopper(context);
	}
	
	
	static ScreenStopper createScreenStopperProcess(Context context)
	{
		return new ScreenStopper(context, 
				STYLE_PROGRESS_PROCESS);
	}

	
	static ScreenStopper createScreenStopperVote(Context context)
	{
		return new ScreenStopper(context,
				STYLE_PROGRESS_VOTE);
	}
	
	
	static ScreenStopper createScreenStopperDraft(Context context)
	{
		return new ScreenStopper(context, 
				STYLE_PROGRESS_DRAFT);
	}

	
	static ScreenStopper createScreenStopperLoading(Context context)
	{
		return new ScreenStopper(context,
				STYLE_PROGRESS_LOADING);
	}

	
	private void createView(Context context, int style)
	{
	    setCancelable(false);

	    if (style != STYLE_STOPPER)
	    {
		  	LayoutInflater factory = LayoutInflater.from(context);
		  	LinearLayout view = (LinearLayout)factory.inflate(R.layout.stopper_bg, null);
		  	TextView tv = (TextView)view.findViewById(R.id.commontxtProgressComment);
		  	
		  	switch (style)
		  	{
		  	case STYLE_STOPPER:				
		  		break;
		  	case STYLE_PROGRESS_PROCESS:	
		  		tv.setText(context.getString(R.string.common_txtProgressProcess));
		  		break;
		  	case STYLE_PROGRESS_VOTE:		
		  		tv.setText(context.getString(R.string.common_txtProgressVote));
		  		break;
		  	case STYLE_PROGRESS_DRAFT:		
		  		tv.setText(context.getString(R.string.common_txtProgressDraft));
		  		break;
		  	case STYLE_PROGRESS_LOADING:	
		  		tv.setText(context.getString(R.string.common_txtLoadingDetail));
		  		break;
		  	}
		  	setView(view);

	    }
	}   
	
}
